subroutine EV(n6,n7,n8,riskret,sav,iy1,tty,gcash,ncash,ninc,V,secd,nweig1,survprob,rho,auxVV)
INTEGER, INTENT(IN) :: ncash,ninc,n6,n7,n8
REAL, INTENT(IN) :: sav, survprob, rho
REAL, INTENT(IN) :: riskret(n8,1), V(ncash,ninc,n7), secd(ncash,ninc,n7), nweig1(n6,n7,n8)!, yh(n7,1)
REAL, INTENT(IN) :: gcash(ncash,1), tty(n6,n8)!, yt1(ninc,n6,n8)
INTEGER, INTENT(IN) :: iy1(n6,n8)
double precision, INTENT(OUT) :: auxVV
double precision :: int_V1, int_V2, int_V
INTEGER :: i6,i7,i8,iy
real :: cash_1
  
auxVV=0.0
do i6=1,n6
   do i8=1,n8
      do i7=1,n7
         cash_1= riskret(i8,1)*sav 
         cash_1 = max(min(cash_1,gcash(ncash,1)),gcash(1,1))
         call sc_splint(gcash(:,1),V(:,iy1(i6,i8),i7),secd(:,iy1(i6,i8),i7),ncash,cash_1,int_V1)
         call sc_splint(gcash(:,1),V(:,iy1(i6,i8)+1,i7),secd(:,iy1(i6,i8)+1,i7),ncash,cash_1,int_V2)
         int_V = (1-tty(i6,i8))*int_V1+tty(i6,i8)*int_V2                 
         auxVV=auxVV+nweig1(i6,i7,i8)*survprob*(int_V**(1.0-rho))
      end do   !i8
   end do      !i7
end do         !i6

end subroutine
